home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Science / RLaB / rlib / tmp_file.r < prev    next >
Text File  |  1994-04-25  |  936b  |  38 lines

  1. //-------------------------------------------------------------------//
  2.  
  3. //  Syntax:    tmp_file ( )
  4.  
  5. //  Description:
  6.  
  7. //  The tmp_file function generates a string, which can be used as a
  8. //  temporary file name. The tmp_file function generates the file name
  9. //  with the help of the system's date program. If your particular
  10. //  platform does not support the date usage as delivered, then modify
  11. //  the argument to system() to get the correct effect.
  12.  
  13. //-------------------------------------------------------------------//
  14.  
  15. static (K);    // to help insure unique name during a session
  16. K = 1;
  17.  
  18. tmp_file = function ( )
  19. {
  20.   local (ans, k, pfile, sans);
  21.  
  22.   //
  23.   //  Generate a date string that looks like hhmmss. That is
  24.   //  numerical hour, minutes, seconds.
  25.   //
  26.  
  27.   pfile = "|date +%H%M%S";
  28.   ans = getline (pfile);
  29.   close (pfile);
  30.  
  31.   sprintf (sans, "%i", ans.[1]);
  32.   sprintf (k, "%i", K);
  33.   K++;
  34.  
  35.   return "rlab-" + sans + "." + k;
  36. };
  37.  
  38.